package com.xjgzinfo.usdp.service.impl;

import com.xjgzinfo.usdp.domain.BladeVisualConfig;
import com.xjgzinfo.usdp.repository.BladeVisualConfigRepository;
import com.xjgzinfo.usdp.service.BladeVisualConfigService;
import com.xjgzinfo.usdp.service.dto.BladeVisualConfigDTO;
import com.xjgzinfo.usdp.service.mapper.BladeVisualConfigMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Optional;

/**
 * Service Implementation for managing {@link BladeVisualConfig}.
 */
@Service
@Transactional
public class BladeVisualConfigServiceImpl implements BladeVisualConfigService {

    private final Logger log = LoggerFactory.getLogger(BladeVisualConfigServiceImpl.class);

    private final BladeVisualConfigRepository bladeVisualConfigRepository;

    private final BladeVisualConfigMapper bladeVisualConfigMapper;

    public BladeVisualConfigServiceImpl(BladeVisualConfigRepository bladeVisualConfigRepository, BladeVisualConfigMapper bladeVisualConfigMapper) {
        this.bladeVisualConfigRepository = bladeVisualConfigRepository;
        this.bladeVisualConfigMapper = bladeVisualConfigMapper;
    }

    @Override
    public BladeVisualConfigDTO save(BladeVisualConfigDTO bladeVisualConfigDTO) {
        log.debug("Request to save BladeVisualConfig : {}", bladeVisualConfigDTO);
        BladeVisualConfig bladeVisualConfig = bladeVisualConfigMapper.toEntity(bladeVisualConfigDTO);
        bladeVisualConfig = bladeVisualConfigRepository.save(bladeVisualConfig);
        return bladeVisualConfigMapper.toDto(bladeVisualConfig);
    }

    @Override
    @Transactional(readOnly = true)
    public Page<BladeVisualConfigDTO> findAll(Pageable pageable) {
        log.debug("Request to get all BladeVisualConfigs");
        return bladeVisualConfigRepository.findAll(pageable)
                .map(bladeVisualConfigMapper::toDto);
    }


    @Override
    @Transactional(readOnly = true)
    public Optional<BladeVisualConfigDTO> findOne(Long id) {
        log.debug("Request to get BladeVisualConfig : {}", id);
        return bladeVisualConfigRepository.findById(id)
                .map(bladeVisualConfigMapper::toDto);
    }

    @Override
    public void delete(Long id) {
        log.debug("Request to delete BladeVisualConfig : {}", id);
        bladeVisualConfigRepository.deleteById(id);
    }
}
